// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import qiankun from "vite-plugin-qiankun";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    qiankun("sub-app1", {
      // 'sub-app1' 是子应用名称
      useDevMode: true, // 开发环境启用 dev mode
    }),
  ],
  server: {
    port: 7701, // 设置端口为 7701
    cors: true, // 允许跨域
    origin: "http://localhost:7701", // 设置 origin
  },
  build: {
    rollupOptions: {
      output: {
        // 确保打包文件名一致，便于主应用加载
        entryFileNames: "assets/[name].js",
        chunkFileNames: "assets/[name].js",
        assetFileNames: "assets/[name].[ext]",
      },
    },
  },
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
  },
});
